
cmake_minimum_required(VERSION 3.4.1)

file(GLOB source_path
    src/main/cpp/player/*.cpp
    src/main/cpp/ffmpeg/*.cpp
    src/main/cpp/ffmpeg/*.c )
set(_DIR ${CMAKE_SOURCE_DIR}/src/main/jniLibs)
include_directories(src/main/cpp/include)


find_library(
              log-lib
              log )

add_library(
             native-lib
             SHARED
             src/main/cpp/native-lib.cpp
             ${source_path} )

add_library(
             libavcodec
             SHARED
             IMPORTED)
set_target_properties(
            libavcodec
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libavcodec.so )

add_library(
             libavdevice
             SHARED
             IMPORTED)
set_target_properties(
            libavdevice
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libavdevice.so )

add_library(
             libavfilter
             SHARED
             IMPORTED)
set_target_properties(
            libavfilter
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libavfilter.so )

add_library(
             libavformat
             SHARED
             IMPORTED)
set_target_properties(
            libavformat
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libavformat.so )

add_library(
             libavutil
             SHARED
             IMPORTED)
set_target_properties(
            libavutil
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libavutil.so )

add_library(
             libpostproc
             SHARED
             IMPORTED)
set_target_properties(
            libpostproc
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libpostproc.so )

add_library(
             libswresample
             SHARED
             IMPORTED)
set_target_properties(
            libswresample
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libswresample.so )

add_library(
             libswscale
             SHARED
             IMPORTED)
set_target_properties(
            libswscale
            PROPERTIES IMPORTED_LOCATION
            ${_DIR}/${ANDROID_ABI}/libswscale.so )


target_link_libraries(
                       native-lib
                       libavcodec
                       libavdevice
                       libavfilter
                       libavformat
                       libavutil
                       libpostproc
                       libswresample
                       libswscale
                       ${log-lib}
                       android
                       OpenSLES
                       #系统库可以不写find_library, log其实可以不用写find_library
                       )